/* GUI CONVERTED from rcsinit.p (converter v1.75) Fri Apr 27 05:43:53 2001 */
/* rcsinit.p - Release Management Customer Schedules                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.6.1.3 $                                                         */
/*V8:ConvertMode=Maintenance                                            */
/* REVISION: 7.0    LAST MODIFIED: 01/29/92           BY: WUG *F110*    */
/* REVISION: 7.2    LAST MODIFIED: 06/03/93           BY: WUG *GB67*    */
/* REVISION: 7.3    LAST MODIFIED: 01/05/94           BY: jxz *F0CX*    */
/* REVISION: 8.6    LAST MODIFIED: 09/20/96           BY: TSI *K005*    */
/* REVISION: 8.6    LAST MODIFIED: 01/27/97           BY: kxn *K057*    */
/* REVISION: 8.6    LAST MODIFIED: 05/20/98           BY: *K1Q4* Alfred Tan */
/* REVISION: 8.6E   LAST MODIFIED: 01/01/2000         BY: *J3NH* Ashwini G  */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00           BY: *N0KP* myb        */
/* Old ECO marker removed, but no ECO header exists *F0PN*                  */
/* $Revision: 1.6.1.3 $     BY: Nikita Joshi     DATE: 04/24/01    ECO: *M15S*      */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

         /* INITIALIZES A SCHEDULE FROM ANOTHER */

/* REPLACED THE LOGIC OF COPYING THROUGH 'NULL' STREAM BY          */
/* BUFFER-COPY STATEMENT                                           */

/*K005*/ {mfdeclre.i}

define input parameter prev_sch_recid as recid.
define input parameter new_sch_recid as recid.
define input parameter det_records like mfc_logical.

define buffer prev_schd_det for schd_det.
define buffer cmtdet for cmt_det.
define variable new_index like cmt_indx.
define variable i as integer.
define variable errgen as logical no-undo.
define variable errlevel as integer no-undo.
define variable append_msg as character no-undo.

define buffer b_sch_mstr for sch_mstr.

/* GET DETAIL ITEMS FROM OLD SCHEDULE MASTER */

find sch_mstr
   where recid(sch_mstr) = new_sch_recid
   exclusive-lock.

if sch_type < 4 then do:
   find so_mstr
      where so_nbr = sch_nbr

      no-lock no-error.
   if not available so_mstr then do:
      {pxmsg.i &MSGNUM=609 &ERRORLEVEL=3}   /* SALES ORDER DOES NOT EXIST */
      undo, return.
   end.
end.

for first b_sch_mstr
      where recid(b_sch_mstr) = prev_sch_recid no-lock:
end.
buffer-copy b_sch_mstr except sch_type sch_nbr sch_line sch_rlse_id
   sch_ship
   to sch_mstr .

/*COPY COMMENT DATA IF ANY*/

if b_sch_mstr.sch_cmtindx <> 0 then
   do:
   {gpcmtcpy.i  &old_index = b_sch_mstr.sch_cmtindx
      &new_index = new_index
      &counter   = i}
   assign sch_mstr.sch_cmtindx = new_index.
end. /* IF B_SCH_MSTR.SCH_CMTINDX <> 0 */

/*NOW COPY DETAIL RECORDS*/

if det_records then do:

   for each prev_schd_det where schd_type    = b_sch_mstr.sch_type
         and schd_nbr     = b_sch_mstr.sch_nbr
         and schd_line    = b_sch_mstr.sch_line
         and schd_rlse_id = b_sch_mstr.sch_rlse_id
         no-lock:
/*GUI*/ if global-beam-me-up then undo, leave.


      if schd_type < 4 then
   do:
         {gprun.i ""rcscmtc.p"" "(input recid(prev_schd_det),
                                     output errgen)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         if errgen then
            undo, return.
      end.

      create schd_det.
      buffer-copy prev_schd_det to schd_det
         assign schd_det.schd_type    = sch_mstr.sch_type
         schd_det.schd_nbr     = sch_mstr.sch_nbr
         schd_det.schd_line    = sch_mstr.sch_line
         schd_det.schd_rlse_id = sch_mstr.sch_rlse_id .
      if recid(schd_det) = -1 then.

      /*COPY COMMENT DATA IF ANY*/
      if schd_det.schd_cmtindx <> 0 then do:
         {gpcmtcpy.i  &old_index = schd_det.schd_cmtindx
            &new_index = new_index
            &counter   = i }
         assign schd_det.schd_cmtindx = new_index.
      end. /* IF SCHD_DET.SCHD_CMTINDX */

      if sch_mstr.sch_type < 4 and
         can-find(first rqm_det
         where rqm_type       = schd_det.schd_type
         and rqm_nbr        = schd_det.schd_nbr
         and rqm_line       = schd_det.schd_line

         and rqm_rlse_id    = b_sch_mstr.sch_rlse_id
         and rqm_date       = schd_det.schd_date
         and rqm_time       = schd_det.schd_time
         and rqm_interval   = schd_det.schd_interval
         and rqm_reference  = schd_det.schd_reference) then
   do:
         find first rqm_det
            where rqm_type       = schd_det.schd_type
            and rqm_nbr        = schd_det.schd_nbr
            and rqm_line       = schd_det.schd_line

            and rqm_rlse_id    = b_sch_mstr.sch_rlse_id
            and rqm_date       = schd_det.schd_date
            and rqm_time       = schd_det.schd_time
            and rqm_interval   = schd_det.schd_interval
            and rqm_reference  = schd_det.schd_reference
            and rqm_cat        = 'AUTHNBR'
            no-lock no-error.

         if so_auth_days <> 0
            and available rqm_det then
      do:
            append_msg = string(rqm_type) + "/" +
               string(rqm_line) + "/" +
               rqm_rlse_id + "/" +
               string(rqm_date,"99-99-99") + "/" +
               string(rqm_time,"99:99") + "/" +
               rqm_value.

            {gprun.i ""gpcfmsg.p"" "(input 1514,
                                        input 0,
                                        input program-name(1),
                                        input so_site,
                                        input so_ship,
                                        input append_msg,
                                        input true,
                                        output errlevel)"}
/*GUI*/ if global-beam-me-up then undo, leave.


            if errlevel > 2 then
               undo, return.
         end. /*IF SO_AUTHDAYS <> 0 */

         /* CHANGED SECOND INPUT PARAMETER FROM PREV_SCH_RLSE_ID TO */
         /* B_SCH_MSTR.SCH_RLSE_ID                                  */
         {gprun.i ""rcsinita.p"" "(input recid(schd_det),
                                            input b_sch_mstr.sch_rlse_id)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      end. /* IF SCH_MSTR.SCH_TYPE */

   end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* FOR EACH PREV_SCHD_DET */
end. /* IF DET_RECORDS */
